package org.gtugs.raffler.master;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.alljoyn.bus.BusException;
import org.alljoyn.bus.BusObject;
import org.gtugs.raffler.interfaces.RaffleMasterInterface;
import org.gtugs.raffler.pojo.Participant;
import org.gtugs.raffler.pojo.Prize;
import org.gtugs.raffler.pojo.Raffle;

public class RaffleService implements RaffleMasterInterface, BusObject {
	
	private List<Raffle> raffleList;
	
	
	

	/**
	 * 
	 */
	public RaffleService() {
		super();
		
		raffleList = new ArrayList<Raffle>();
		
		
	}

	@Override
	public HashMap<Prize, Participant> getFinalDrawing(Raffle arg0)
			throws BusException {
		
		return arg0.getWinnerList();
	}

	@Override
	public List<Participant> getParticipants(Raffle arg0) throws BusException {
		return arg0.getParticipants();
		
	}

	@Override
	public List<Prize> getPrize(Raffle arg0) throws BusException {
		
		return arg0.getPrizes();
	}

	@Override
	public List<Raffle> getRaffles() throws BusException {
		
		return raffleList;
	}

	@Override
	public boolean registerForRaffle(Raffle arg0, Participant arg1)
			throws BusException {
		
		return arg0.addParticipant(arg1);
	}
	
	public void createRaffle(Raffle r) {
		raffleList.add(r);
	}

}
